// 路由表

import 'package:lepig/pages/incomeDetails/Income.dart';
import 'package:lepig/pages/init/Init.dart';
import 'package:lepig/pages/myCollection/MyCollection.dart';
import 'package:lepig/pages/myOrder/MyOrder.dart';
import 'package:lepig/pages/myTeam/MyTeam.dart';
import 'package:lepig/pages/product/Product.dart';
import 'package:lepig/pages/search/Search.dart';
import 'package:lepig/pages/setting/Setting.dart';
import 'package:lepig/pages/share/Share.dart';
import 'package:lepig/pages/withdraw/Withdraw.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lepig/pages/withdraw/WithdrawLists.dart';

final Map<String, WidgetBuilder> routeTable = {
  '/': (content) => initPage(),
  '/search': (context){
    return Search(searchModel:ModalRoute.of(context).settings.arguments);
  },
  '/product': (context) {
    return Product(ModalRoute.of(context).settings.arguments);
  },
  '/setting': (context) => Setting(),
  '/withdraw': (context) => Withdraw(),
  '/withdrawLists': (context) => WithdrawLists(),
  '/share': (context) => Share(),
  '/income': (context) => Incom(),
  '/myOrder': (context) => MyOrder(),
  '/myTeam': (context) => MyTeam(),
  '/myCollection': (context) => MyCollection(),
};
// 动态生成路由
final onGenerateRoute = (RouteSettings settings) {
  // 从路由表得到builder
  final name = settings.name;
  print(routeTable);
  print(name);
  var builder = routeTable[name];
  // 如果路由表中未定义，跳转到未定义路由页面
  if (builder == null) {
    print("路由不存在");
  }
  // 构建动态的route
  final route = CupertinoPageRoute(
    builder: builder,
    settings: settings,
  );
  return route;
};

class NotFoundPage {}
